function qryAllOrder(acctId, userType) {
    $
            .ajax({
                url : "/SofaGuest/order/qryAllOrder.do",
                type : "post",
                data : {
                    "userId" : acctId,
                    "userType" : userType
                },
                dataType : "json",
                success : function(result) {
                    if ("0000" == result.status) {
                        // alert(result.detial);
                        $("#ordertablebodyend").html("");
                        $("#ordertablebodfailed").html("");
                        $("#ordertablebodyon").html("");
                        $("#ordertablebody").html("");
                        var orders = result.data;
                        for ( var i = 0; i < orders.length; i++) {
                            var orderId = orders[i].order_id;
                            var userName = orders[i].user_name;
                            var userTel = orders[i].user_tel;
                            var startDate = orders[i].start_date;
                            var endDate = orders[i].end_date;
                            var orderStatus = orders[i].order_status;
                            var strStatus = transOrderStatus(orderStatus);// 转换订单状态用于显示
                            var tr = '<tr><td width="">' + orderId + '</td><td width="">' + userName + '</td>'
                                    + '<td width="">' + userTel + '</td><td width="">' + startDate + '</td>'
                                    + '<td width="">' + endDate + '</td><td width="">' + strStatus + '</td>';
                            if (4 == orderStatus) { // 已完成订单
                                $("#ordertablebodyend").append(tr + '</tr>');
                            }
                            else if (5 == orderStatus) {// 退单
                                tr = tr + '<td width="">' + orders[i].para_value + '</td></tr>';
                                $("#ordertablebodfailed").append(tr);
                            }
                            else {// 未完成订单
                                var thistr = '<tr><td width="">' + orderId + '</td><td width="">' + userName + '</td>'
                                        + '<td width="">' + userTel + '</td><td width="">' + startDate + '</td>'
                                        + '<td width="">' + endDate + '</td><td width="">' + strStatus + '</td>';
                                if ("1" == userType) {// 沙客
                                    if (1 == orderStatus) {// 待接单
                                        thistr = thistr + '<td width="">待接单</td>';
                                    }
                                    else if (2 == orderStatus) {
                                        thistr = thistr
                                                + '<td width=""><input type="button" class="titlebut" onclick="overOrder(this)" value="离开" /></td>';
                                    }
                                    else {// 评价
                                        thistr = thistr
                                                + '<td width=""><input type="button" class="titlebut" onClick="comment(this)" value="评价" /></td>';
                                    }
                                }
                                else {
                                    if (1 == orderStatus) {// 待接单
                                        thistr = tr
                                                + '<td width=""><input type="button" class="titlebut" onclick="modifyOrderStatus(2,this)" value="接单" />'
                                                + '<input type="button" class="titlebut" onclick="modifyOrderStatus(5,this)" value="退单" /></td>';
                                    }
                                    else if (2 == orderStatus) {
                                        thistr = thistr + '<td width="">待入住</td>';
                                    }
                                    else {
                                        thistr = thistr + '<td width="">待评价</td>';
                                    }
                                }
                                thistr = thistr + '</tr>';
                                $tr = $(thistr);
                                $tr.data("orderId", orderId);
                                $("#ordertablebodyon").append($tr);
                            }
                            // 所有订单
                            $("#ordertablebody").append(tr + '</tr>');
                        }
                    }
                },
                error : function() {
                    alert("系统异常,请稍后重试");
                }
            });
}

// 离开
function overOrder(tr) {
    // 修改订单状态
    modifyOrderStatus(3, tr);
    // 评价
    comment(tr);
}

// 评价
function comment(tr) {
    $("#content").val("");
    to_write();
    var $tr = $(tr);
    var orderId = $tr.parent().parent().data("orderId");
    addCookie("orderId", orderId, 2);
}
